package com.siwei.mes.entity.orderDetail;

import com.alibaba.fastjson.JSONObject;
import com.siwei.mes.common.util.JsonUtils;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.experimental.Accessors;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

/**
 * @Description: 强度回弹
 * @Version: 1.0
 * @author: chenmaolin
 * @date: 2023/12/10 19:53
 */
@Data
@Accessors(chain = true)
public class QDHTDetail {
    @ApiModelProperty(value = "仪器编号")
    private String yqbh = "";

    @ApiModelProperty(value = "回弹检测部位")
    private String htjcbw = "";

    @ApiModelProperty(value = "构件龄期")
    private String gjlq = "";

    @ApiModelProperty(value = "强度结果")
    private String qdjg = "";

    @ApiModelProperty(value = "回弹信息集合")
    private List<HtInfo> htInfoList = new ArrayList();

    @Data
    @Accessors(chain = true)
    public static class HtInfo {
        @ApiModelProperty(value = "回弹位置")
        private String htwz = "";

        @ApiModelProperty(value = "回弹强度")
        private String htqd = "";

        @ApiModelProperty(value = "回弹图片")
        private String htimg = "";
    }

    /**
     * 字符串转成对象 然后再转成json
     *
     * @param object
     * @return
     */
    public static JSONObject toJsonObject(Object object) {
        QDHTDetail entity = new QDHTDetail();
        if (object == null) {
            return JsonUtils.beanToObject(entity);
        }
        if (object instanceof String) {
            entity = JsonUtils.getObject((String) object, QDHTDetail.class);
        } else if (object instanceof JSONObject) {
            entity = JsonUtils.getObject((JSONObject) object, QDHTDetail.class);
        }
        return JsonUtils.beanToObject(entity);
    }

}
